#include "algo.h"

static bool
hasNoEdge(Graph *graph) {
	for (int i = 0 ; i < graph->getNbVertex(); i++) {
		if (graph->numEdge(i) > 0)return false;
	}
	return true;
}


//renvoie la liste des sommets couvrants
vector<int>
glouton(const Graph *graph) {
	vector<int> coverVertexes;
	Graph *copy = graph->copy();
	while(!hasNoEdge(copy)) {
		int indiceMax = 0;
		for (int i = 1; i<copy->getNbVertex(); i++){
			if(copy->numEdge(i) > copy->numEdge(indiceMax))
			{
				indiceMax = i;
			}
		}
		coverVertexes.push_back(indiceMax);
		copy->delVertex(indiceMax);
	}
	return coverVertexes;
}


